package com.zhentao.controller;

import com.zhentao.admin.domain.AdUser;
import com.zhentao.admin.pojo.UserDto;
import com.zhentao.common.dtos.ResponseResult;
import com.zhentao.service.AdUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api("/manager")
@RestController
@RequestMapping("/manager")
public class LoginController {

    @Resource
    private AdUserService adUserService;

    /**
     * 后台管理员 用户登录
     * @param dto
     * @return
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "UserDto", name = "dto", value = "", required = true)
    })
    @ApiOperation(value = "后台管理员 用户登录", notes = "后台管理员 用户登录", httpMethod = "POST")
    @PostMapping("/login")
    public ResponseResult login(@RequestBody UserDto dto) {
        return adUserService.login(dto);
    }

    /**
     * 后台 注册新的用户
     * @param adUser
     * @return
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "AdUser", name = "adUser", value = "", required = true)
    })
    @ApiOperation(value = "后台 注册新的用户", notes = "后台 注册新的用户", httpMethod = "POST")
    @PostMapping("/regiestManage")
    public ResponseResult regiestManage(@RequestBody AdUser adUser){
        return  adUserService.regiestManage(adUser);
    }
}
